/*
 * @Author: SuperficialL
 * @Date: 2020-07-04 23:06:58
 * @LastEditTime: 2021-01-18 16:15:15
 * @Description: 友链数据
 */
import { getLinks } from "../../api/global";

export const state = () => {
  return {
    fetching: false,
    data: [],
  };
};

export const mutations = {
  updateFetching(state, res) {
    state.fetching = res;
  },
  updateListData(state, res) {
    state.data = res.data;
  },
};

export const actions = {
  fetchList({ commit }, params) {
    return getLinks(params)
      .then((res) => {
        commit('updateListData', res.result);
      })
      .catch((err) => {
        return Promise.reject(err);
      });
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions
};